package com.lex.jfb;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.MenuItem;
import android.widget.Toast;

public abstract class BaseActivity extends AppCompatActivity {

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ActionBar actionBar = getSupportActionBar();
        if(actionBar == null) return;
        actionBar.setDisplayShowCustomEnabled(true);
        actionBar.setCustomView(R.layout.actionbar_custom_layout);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        if(item.getItemId() == android.R.id.home)
            finish();
        return super.onOptionsItemSelected(item);
    }

    protected abstract void findView();
    protected abstract void initView();

    public void showShortToast(String str){
        Toast.makeText(this,str,Toast.LENGTH_SHORT).show();
    }

    public void showShortToast(int strResId){
        Toast.makeText(this,strResId,Toast.LENGTH_SHORT).show();
    }

    public void showLongToast(String str){
        Toast.makeText(this,str,Toast.LENGTH_LONG).show();
    }

    public void showLongToast(int strResId){
        Toast.makeText(this,strResId,Toast.LENGTH_LONG).show();
    }

    public void log(String str){
        Log.d("LexLog",str);
    }
}